﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Utility1;

namespace eDream.admin
{
    public partial class nap_tien : System.Web.UI.UserControl
    {
        public string pathUrl = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            pathUrl = WebUtils.pathUrl();
        }

        void bindata()
        {
            DataClasses1DataContext dx = new DataClasses1DataContext();
            try
            {
                int phi = getPhidong();
                dx.Connection.Open();
                var list = from k in dx.UserDBs
                           where (k.money > 0 && k.money < phi)
                           select new { k.ID, k.kichhoat, k.Lastname, k.UserName, k.TuvanName, k.phone, k.nguoigioithieu, k.money, k.FirtName, k.email };
                grvNaptien.DataSource = list;
                grvNaptien.DataBind();
            }
            catch (Exception) { }
            finally { dx.Connection.Close(); }
        }

        int getPhidong()
        {
            int phidong = 0;
            DataClasses1DataContext dx = new DataClasses1DataContext();
            try
            {
                dx.Connection.Open();
                var list = from k in dx.config_mucHoahongs
                           where k.ID == "Thuphi"
                           select k;
                foreach (config_mucHoahong cf in list)
                    phidong = (int)cf.Value;

            }
            catch (Exception) { }
            finally { dx.Connection.Close(); }
            return phidong;
        }
        protected void grvNaptien_Load(object sender, EventArgs e)
        {
            bindata();
        }
    }
}